<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>立体呈现</title>
    <style>
        .cube {
            width: 200px;
            height: 200px;
            margin: 100px auto;
            background-color: pink;
            position: relative;
            /* 开启3d空间属性 */
            transform-style: preserve-3d;
            transition: all 15s;
        }
    
        .front {
            position: absolute;
            width: 200px;
            height: 200px;
            z-index: 1;
            /* 让前面的盒子往前走 位移 */
            transform: translateZ(200px);
            background-color: orange;
    
        }
    
        .back {
            /* 定位流派层级默认是相同的
            html结构写在后面会展示
            强行显示z-index */
            position: absolute;
            z-index: 2;
            width: 200px;
            height: 200px;
            background-color: plum;
            transform: rotateY(180deg);
        }
        .left{
            width: 200px;
            height: 200px;
            position: absolute;
            z-index: 3;
            transform: rotateY(90deg)  translateX(-100px) translateZ(100px);
            background-color: yellowgreen;
        }
        .right{
            width: 200px;
            height: 200px;
            position: absolute;
            z-index: 4;
            transform: rotateY(90deg) translateX(-100px) translateZ(-100px);
            background-color: pink;
        }

        /* 转起来 */
        .cube:hover{
            transform: rotateY(-360deg);
        }
    </style>
    </head>
    
    <body>
        <div class="cube">
            <div class="front">前面</div>
            <div class="left">左边</div>
            <div class="right">右边</div>

            <div class="back">后面</div>
        </div>
    </body>
    
    </html>